//
//  SetPassView.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2017/11/17.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "SetPassView.h"

@implementation SetPassView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = CSWhiteColor;
        
        NSMutableDictionary *attrs = [NSMutableDictionary dictionary];// 创建属性字典
        attrs[NSFontAttributeName] = MidBigFont; // 设置font
        attrs[NSForegroundColorAttributeName] = PlaceHoldColor; // 设置颜色
        
        /**
         设置登录密码
         */
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.text = @"设置登录密码";
        titleLabel.font = BoldBigFont;
        titleLabel.textColor = CSColorFromRGB(0x0a0a0a);
        [self addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
        /**
         密码TF
         */
        UITextField *passWordTF = [[UITextField alloc] init];
        //        passWordTF.backgroundColor = CSRedColor;
        passWordTF.secureTextEntry = YES;
//        passWordTF.clearButtonMode=UITextFieldViewModeWhileEditing;
        NSAttributedString *passAttStr = [[NSAttributedString alloc] initWithString:@"请输入密码,至少六位" attributes:attrs]; // 初始化富文本占位字符串
        passWordTF.attributedPlaceholder = passAttStr;
        passWordTF.font = MidBigFont;
        passWordTF.textColor = CSColorFromRGB(0x212121);
        [self addSubview:passWordTF];
        self.passWordTF = passWordTF;
        
        /**
         明文密文显示
         */
        UIButton *lookBtn = [[UIButton alloc] init];
        [lookBtn setImage:[UIImage imageNamed:@"icon_eyes_gary"] forState:UIControlStateNormal];
        [lookBtn setImage:[UIImage imageNamed:@"icon_eyes"] forState:UIControlStateSelected];
        [self addSubview:lookBtn];
        self.lookBtn = lookBtn;
        
        UIView *accountLineView1 = [[UIView alloc] init];
        accountLineView1.backgroundColor = LineBackGroundColor;
        [self addSubview:accountLineView1];
        self.accountLineView1 = accountLineView1;
        
        /**
         下一步按钮
         */
        UIButton *nextBtn = [[UIButton alloc] init];
        nextBtn.backgroundColor = ButtonBackGroundColor;
        nextBtn.layer.cornerRadius = 4;
        nextBtn.layer.masksToBounds = YES;
        [nextBtn setTitle:@"下一步"forState:UIControlStateNormal];
        [nextBtn setTitleColor:CSBlackColor forState:UIControlStateNormal];
        nextBtn.titleLabel.font = BigFont;
        [self addSubview:nextBtn];
        self.nextBtn = nextBtn;
        
        [self setConstraints];
    }
    
    return self;
}


-(void)setConstraints{

    /**
     设置登录密码
     */
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self).offset(15);
        
        make.left.mas_equalTo(self).offset(25);
        
        make.height.mas_equalTo(60);
    }];
    
    /**
     密码TF
     */
    [self.passWordTF mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self).offset(25);
        
        make.right.mas_equalTo(self).offset(-25);
        
        make.height.mas_equalTo(40);
        
    }];
    
    /**
     明文密文显示
     */
    [self.lookBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self).offset(-15);
        
        make.centerY.mas_equalTo(self.passWordTF);
    }];
    
    [self.accountLineView1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.width.mas_equalTo(self.passWordTF);
        
        make.height.mas_equalTo(1);
        
        make.top.mas_equalTo(self.passWordTF.mas_bottom).offset(10);
        
    }];
    
    //下一步
    [self.nextBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.accountLineView1.mas_bottom).offset(35);
        
        make.left.mas_equalTo(self).offset(30);
        
        make.right.mas_equalTo(self).offset(-30);
        
        make.height.mas_equalTo(50);
    }];
}

@end
